<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style>
            *{
                margin: 0px;
                padding: 0px;
                list-style: none;

            }
            ul{
                overflow: hidden;
            }
            ul li{
                float: left;
                width: 100px;
                height: 30px;
                margin-right: 10px;
            }
            ul li:nth-of-type(1){
                background:gray;
            }
            section>div{
                width: 500px;
                height: 200px;
                text-align: center;
                display: none;
            }
            section>div:nth-of-type(1){
                display: block;
            }
        </style>
    </head>
    <body>
        <ul>
            <li>汉堡披萨</li>
            <li>快餐便当</li>
            <li>奶茶果汁</li>
            <li>龙虾烧烤</li>
            <li>家常菜</li>
        </ul>
        <section>
            <div>金拱门
                <br><br>
                肯德基
            </div>
            <div>深夜食堂
                <br><br>
                深井寿司
            </div>
            <div>喜茶
                <br><br>
                一点点
            </div>
            <div>湛江烧蚝
                <br><br>
                河边烧烤
            </div>
            <div>东北饺子馆
                <br><br>
                老师傅私房菜
            </div>
        </section>
        <script>
            var tags=document.getElementsByTagName('li');
            var boxs=document.getElementsByTagName('div');
            for(var i=0;i<tags.length;i++){
                tags[i].index=i;
                tags[i].onclick=function(){
                    for(var j=0;j<tags.length;j++){
                        tags[j].style.background="none";
                        boxs[j].style.display="none"
                    }
                    this.style.background='gray';
                    var n=this.index;
                    boxs[n].style.display='block'
                }
            }
        </script>
    </body>
</html>